<?
//require('session.php');
session_start();
// Set the content-type
//for ($i=48; $i<92; $i++) echo chr( $i ); exit();
//0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ
header('Content-type: image/png');

// Create the image
$im = imagecreatetruecolor(300, 60);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey  = imagecolorallocate($im, 91, 90, 99);
$black = imagecolorallocate($im,20, 19, 23);

imagefilledrectangle($im, 0, 0, 399, 69, $grey);
//imagecolortransparent  ( $im ,$grey );
// The text to draw

$text = '';
for($i=0;$i<5;$i++){
	// 0061 007A
	//$text.=chr( rand(97,122) );
	$tst=rand(0,35);
	$text.=(($tst>9)?chr( $tst+7+48 ):chr( $tst+48 ));
}
$_SESSION['caphaText']=$text;
// Replace path by your own font path
$font = '../fonts/ariblk.ttf';

// Add some shadow to the text
//imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text

if(empty($_GET['egg'])) for($i=0,$pos=80; $i<strlen($text);$i++){
	$s=rand(18,24);
	//$r=rand(0,10)-5;
	imagettftext($im, $s, 0, $pos, $s*2, $black, $font, $text[$i]);
//	imagefontwidth(int font)
	$pos+=$s+$s*.4;
}else{
	imagefilledrectangle($im, 0, 0, 399, 69, $black);
	imagettftext($im, 38, 0, 30, 40, $white, $font, 'Xy*');
}

$msk=imagecreatefrompng('../img/mask.png');
$tst=getimagesize('../img/mask.png');
imagecopy  ( $im  , $msk , 0 , 0  , 0  , 0  , $tst[0], $tst[1] );

// Using imagepng() results in clearer text compared with imagejpeg()
imagegif($im);
imagedestroy($im);
?>
